{include file="public/header"/}
<body>
<div class="layui-fluid" id="LAY-component-layer-list">
    <div class="layui-card">
        <div class="layui-card-body table-tool-mini">
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <a href="{:url('/filemanager/index')}" class="layui-btn layui-btn-primary input-btn-back">
                        <i class="layui-icon layui-icon-left"></i></a>
                        <button class="layui-btn icon-btn" data-url="{:url('/filemanager/newfile',array('activepath'=>replace_path($activepath)))}" data-type="newfile"><i class="layui-icon">&#xe654;</i>添加文件</button>
                    </div>                    
                </div>
            </div>
            <table class="layui-table" id="tablelist" lay-filter="tablelist"></table>
        </div>
    </div>
</div>
<script type="text/html" id="tableBarUser">
<a class="layui-btn layui-btn-primary layui-btn-sm" data-type="admin_edit">编辑</a>
</script>
{include file="public/footer"/}
<script>
layui.use(['layer', 'form', 'table'], function () {
    var $ = layui.$,
        form = layui.form,
        table = layui.table;
    var inpath1= "{$inpath}";
    var activepath1 ="{$activepath}";

        // 渲染表格
        var insTb = table.render({
            elem: '#tablelist',
            where: {inpath:inpath1,activepath:activepath1},
            method: 'post',
            url: "{:url('/filemanager/lists')}",
            page: true,
            cellMinWidth:100,
            cols: [[
                {field: 'filename', title: '文件名'},
                {field: 'filesize', title: '文件大小', width:150},
                {field: 'filetime', title: '更新时间', width:250},
                {align: 'center', toolbar: '#tableBarUser', title: '操作', width:150}
            ]]
        });

        $(document).on("click","#LAY-component-layer-list .layui-btn",function(){
          var type = $(this).data('type');
          active[type] && active[type].call(this);
        });

        var active = {
            newfile: function(){
              var iframes = layer.open({
                  type: 2,
                  title: '新建文件',
                  fixed: true,
                  shadeClose: false,
                  shade: 0.3,
                  content: $(this).attr('data-url')
              });
              layer.full(iframes);
            },
            edit: function(){
              var iframes = layer.open({
                  type: 2,
                  title: '编辑文件',
                  fixed: true,
                  shadeClose: false,
                  shade: 0.3,
                  content: $(this).attr('data-url')
              });
              layer.full(iframes);
            },
            replace_img: function(){
              var iframes = layer.open({
                  type: 2,
                  title: '替换图片',
                  fixed: true,
                  shadeClose: false,
                  shade: 0.3,
                  content: $(this).attr('data-url')
              });
              layer.full(iframes);
            }
        }
});
</script>
